<!DOCTYPE html>
<html style="z-index: 0;">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body style="z-index: 999;">
   
        <div class="aui-searchbar aui-bg-warning">
                <div class="aui-searchbar-input aui-border-radius" id="keyword">
                    <input  type="search" placeholder="搜淘宝/天猫宝贝，购物更省钱" font-color="ffffff" id="search_input">
                </div>
                <div class="search1" tapmode onclick="doSearch()"><img src="../../image/08.png"/></div>
                <div tapmode onclick="doSign()">
                    <div class="Sign_in" >
                        <img src="../../image/search.png" >
                        
                    </div>
                    <div class="selectfont" id="sign">签到</div>
                </div>
              
        </div>
    <div id="aui-slide3">
       
    </div>
    <div class="aui-content aui-pull-left aui-margin-t-5" id="MKtheme_content"> 
        <div class="news">
            <span>通知</span>
            <span><img src="../../image/tttt.png"></span>
            <span>（喜讯）芒客商城用户突破5万人</span>
        </div>
        <div class="litile1">
            <span class="hs1">活色&nbsp;</span>
            <span class="dian"></span>
            <span class="hs2">&nbsp;生鲜</span>
        </div>
        <div id="aui-main-box">
            
        </div>
    </div>          
    <div class="list_1" tapmode onclick="genduo();"><p>更多商品</p></div>
    <div class="litile2">
        <span class="hs3">品牌&nbsp;</span><span class="dian"></span><span class="hs4">&nbsp;直销</span>
    </div>
    <div id="product">
       
    </div>
    <div class="list_2" tapmode onclick="genduo();"><p>更多商品</p></div>
    <div class="list_3"><p>专栏活动</p></div>
    <div class="list_4"><img src="../../image/xssc9.png"></div>
    
</body>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/aui-slide.js"></script>
    <script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript">
    

    apiready = function() {
        var token = {
            token:$api.getStorage('token')
        };
        if(!$api.getStorage('token')){
                api.toast({
                    msg:'您还未登录，请先登录！',
                    duration:2000
                });
                location.href='../login.html';
                return false;
            }
        //调出虚拟键盘搜索
        $("#keyword").on('keypress',function(e) {
                var keycode = e.keyCode;
                var searchName = $(this).val();
                if(keycode=='13') {
                    e.preventDefault();  
                    //请求搜索接口
                    // alert("123")
                    window.doSearch();
                }
         });

         //banner渲染
         function banner () {
             api.ajax({
                 url:"https://www.samlion.com/goodsapi.php?banner=app_banner",
                 method:"get",
                 dataType:"text",
                 "headers":{
                     "Content-Type":"application/json"
                 },
             },function(ret,err) {
                //  alert(ret);
                //  alert(JSON.stringify(ret));
                 var imgT = ret
                 var imgT2 = ret
                 var imgT3 = ret
                //  alert(imgT);
                 if(ret) {
                     $api.byId("aui-slide3").innerHTML = 
                     '<div class="aui-slide-wrap">'+
                        '<div class="aui-slide-node bg-dark">'+
                            '<img src="'+imgT+'" />'+
                        '</div>'+
                        '<div class="aui-slide-node bg-dark">'+
                            '<img src="'+imgT2+'" />'+
                        '</div>'+
                        '<div class="aui-slide-node bg-dark">'+
                            '<img src="'+imgT3+'" />'+
                        '</div>'+
                    '</div>'+
                    '<div class="aui-slide-page-wrap">'+
                        '<span>1</span>'+
                        '<span>2</span>'+
                        '<span>3</span>'+
                    '</div>'
                    
                 }
                 var slide = new auiSlide({
                    container: document.getElementById("aui-slide3"),
                    "height": 170,
                    "speed": 1000,
                    "autoPlay": 5000,
                    "pageShow": true,
                    "pageStyle": 'dot',
                    "loop": true,
                    'dotPosition': 'center'
                });
             });
         };
         banner();
        //调出后台数据，动态渲染首页图片
         function showGoods() {
            api.ajax({
                url: 'http://www.samlion.com/goodsapi.php?app=8',
                method: 'get',
                dataType: 'json',
                "headers": {
                    "Content-Type": "application/json"
                },
                // data: {
                //     app:"1"   
                // }
            }, function(ret, err) {
                // alert(JSON.stringify(ret));
                if (ret) {
                var id = ret[0].id;
                var img =  ret[0].img;
                var title = ret[0].title;
                var price = ret[0].price;
                var id1 = ret[1].id;
                var img1 =  ret[1].img;
                var title1 = ret[1].title;
                var price1 = ret[1].price;
                var id2 = ret[2].id;
                var img2 =  ret[2].img;
                var title2 = ret[2].title;
                var price2 = ret[2].price;
                var id3 = ret[3].id;
                var img3 =  ret[3].img;
                var title3 = ret[3].title;
                var price3 = ret[3].price;
                var appa = $api.byId('aui-main-box').innerHTML;
                $api.byId('aui-main-box').innerHTML = 
                '<div class="aui-col-xs-66" tapmode onclick="openmZhuang(' + id + ');">' +    
                    '<img src= "http://www.samlion.com/' + img + '">'+
                    '<p class= "line-limit-length">'+ title +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price +'&nbsp;</p>'+
                '</div>'+
                '<div class="aui-col-xs-13" tapmode onclick="mihoutao(' + id1 + ');">'+
                    '<img src= "http://www.samlion.com/' + img1 + '">'+
                    '<p class= "line-limit-length">'+ title1 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price1 +'&nbsp;</p>'+
                '</div>'+
                '<div class="aui-col-xs-6" tapmode onclick="openClose(' + id2 + ');">'+
                    '<img src= "http://www.samlion.com/' + img2 + '">'+
                    '<p class= "line-limit-length">'+ title2 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price2 +'&nbsp;</p>'+
                '</div>'+
                '<div class="aui-col-xs-13" tapmode onclick="worthBuy(' + id3 + ');">'+
                    '<img src= "http://www.samlion.com/' + img3 + '">'+
                    '<p class= "line-limit-length">'+ title3 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price3 +'&nbsp;</p>'+
                '</div>';
                // alert(title);
                // alert(price);
            }
            });
         };
         showGoods();
         //产品直销
         function product() {
            api.ajax({
                url: 'http://www.samlion.com/goodsapi.php?app=3',
                method: 'get',
                dataType: 'json',
                "headers": {
                    "Content-Type": "application/json"
                },
                // data: {
                //     app:"1"   
                // }
            }, function(ret, err) {
                // alert(JSON.stringify(ret));
                if (ret) {
                var id4 = ret[0].id;
                var img4 =  ret[0].img;
                var title4 = ret[0].title;
                var price4 = ret[0].price;
                var id5 = ret[1].id;
                var img5 =  ret[1].img;
                var title5 = ret[1].title;
                var price5 = ret[1].price;
                var id6= ret[2].id;
                var img6 =  ret[2].img;
                var title6 = ret[2].title;
                var price6 = ret[2].price;
                var id7 = ret[3].id;
                var img7 =  ret[3].img;
                var title7 = ret[3].title;
                var price7 = ret[3].price;
                var id8 = ret[4].id;
                var img8 =  ret[4].img;
                var title8 = ret[4].title;
                var price8 = ret[4].price;
                var id9 = ret[5].id;
                var img9 =  ret[5].img;
                var title9 = ret[5].title;
                var price9 = ret[5].price;
                var id10 = ret[6].id;
                var img10 =  ret[6].img;
                var title10 = ret[6].title;
                var price10 = ret[6].price;
                var id11 = ret[7].id;
                var img11 =  ret[7].img;
                var title11 = ret[7].title;
                var price11 = ret[7].price;
                var appa = $api.byId('aui-main-box').innerHTML;
                $api.byId('product').innerHTML = 
                '<ul class="ssxcList">'+
                    '<li tapmode onclick="Direct_selling1(' + id4 + ');">'+
                        '<img src= "http://www.samlion.com/' + img4 + '">'+
                        '<p class= "line-limit-length">'+ title4 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price4 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling2(' + id5 + ');">'+
                        '<img src= "http://www.samlion.com/' + img5 + '">'+
                        '<p class= "line-limit-length">'+ title5 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price5 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling3(' + id6 + ');">'+
                        '<img src= "http://www.samlion.com/' + img6 + '">'+
                        '<p class= "line-limit-length">'+ title6 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price6 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling4(' + id7 + ');">'+
                        '<img src= "http://www.samlion.com/' + img7 + '">'+
                        '<p class= "line-limit-length">'+ title7 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price7 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling5(' + id8 + ');">'+
                        '<img src= "http://www.samlion.com/' + img8 + '">'+
                        '<p class= "line-limit-length">'+ title8 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price8 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling6(' + id9 + ');">'+
                        '<img src= "http://www.samlion.com/' + img9 + '">'+
                        '<p class= "line-limit-length">'+ title9 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price9 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling7(' + id10 + ');">'+
                        '<img src= "http://www.samlion.com/' + img10 + '">'+
                        '<p class= "line-limit-length">'+ title10 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price10 +'&nbsp;</p>'+
                    '</li>'+
                    '<li tapmode onclick="Direct_selling8(' + id11 + ');">'+
                        '<img src= "http://www.samlion.com/' + img11 + '">'+
                        '<p class= "line-limit-length">'+ title11 +'&nbsp;</p>'+
                    '<p class= "line-limit-length">￥'+ price11 +'&nbsp;</p>'+
                    '</li>'+
                    
                '</ul>'
                // alert(img4);
            }
            });
         }
         product();
         //先验证后进淘宝
        window.doSearch = function() {
            var search_input = $api.byId('search_input');
            var search_inputVal = search_input.value;
            if(!$api.getStorage('token')){
                api.toast({
                    msg:'您还未登录，请先登录！',
                    duration:2000
                });
                location.href='../login.html';
                return false;
            }else if (search_inputVal != '') {
                
                        var unid =$api.getStorage("uid");
                        var u = $api.getStorage("uid");
                        // alert(u);
                        api.openWin({
                            name: 'formwork_2',
                            url: '../formwork_2.html',
                            pageParam: {
                                unid: unid,
                                u: u,
                                search_inputVal: search_inputVal
                            },
                            allowEdit: true
                        });
                    } else {
                        // alert(JSON.stringify(err));
                    }
                // });
            // }
        }
        //返回
        api.addEventListener({
        　　　　name: 'keyback'
        　　}, function(ret, err) {
        // 　　　　api.closeFrame({
        // 　　　　　　name: 'index'
        // 　　　　});
            api.historyBack({
                frameName: 'home' 
            }, function(ret, err) {
                if (!ret.status) {
                    api.closeWin();
                }
            });
        　});
        //商品详情去雄狮
        window.Direct_selling1 = function(id4) {
            // var header = $api.dom('header');
            // var headerH = $api.fixStatusBar(header)+10;
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id4 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling2 = function(id5) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id5 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling3 = function(id6) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id6 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling4 = function(id7) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id7 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling5 = function(id8) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id8 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling6 = function(id9) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id9 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling7 = function(id10) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id10 + 'name=' + uid
                }
            });  
        }
        window.Direct_selling8 = function(id11) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name:'xionngS',
                url:'../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id11 + 'name=' + uid
                }
            });  
        }
        //签到
        var flag = false;
        window.doSign = function (){
            if(flag){
                return false;
            }
            flag = true;

            api.ajax({
                url:'http://www.mk517.com/webApi/sign.php',
                method:'post',
                dataType:'json',
                'headers':{
                    'Content-Type':'application/json'
                },
                data:{
                    body:token
                }
            },function(ret,err){
                if(ret.status){
                    api.toast({
                        msg:'今日已签到',
                        duration:2500,
                        location:'top'
                    });
                }else{
                    api.toast({
                        msg:'签到成功,集分宝+5',
                        duration:2000,
                        location:'top'
                    });
                }
                    flag = false;

            });

        }



        window.changeFrame = function(index) {
            api.openWin({
                name: 'formwork_1',
                url: '../formwork_1.html',
                pageParam: {
                    index: index
                },
                allowEdit: true
            });

        }
        //橙子
        window.openmZhuang = function(id) {
            var uid =  $api.getStorage('uid');
            // var id = ret.id[0];
            // alert(id);
            api.openWin({
                name: 'mZhuang',
                url: '../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 50,
                    w: 'auto',
                    h: 'auto',
                    reload:'true',
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id + 'name=' + uid
                }
            });
        }
        //猕猴桃
        window.mihoutao = function(id1) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name: 'mihoutao',
                url: '../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id1 + 'name=' + uid
                }
            });
        }

        window.openMKTJ = function() {
            api.openFrame({
                name: 'mk',
                url: './mk.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
            });

        }
        window.genduo = function() {
            api.openWin({
                name: 'genduo',
                url: '../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/category.php?id=1"
                }
            });
        }
        //鸡蛋
        window.openClose = function(id2) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name: 'closes',
                url: '../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id2 + 'name=' + uid
                }
            });
        }
        window.openHT = function() {
            api.openFrame({
                name: 'HT',
                url: './HT.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                }
            });

        }
        //苹果
        window.worthBuy = function(id3) {
            var uid =  $api.getStorage('uid');
            api.openWin({
                name: 'worthBuy',
                url: '../main/mZhuang.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam:{
                    url:"http://www.samlion.com/mobile/goods.php?id="+ id3 + 'name=' + uid
                }
            });

        }

        window.openwumi = function() {
            api.openFrame({
                name: 'wumi',
                url: '../wumi/wumi.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
            });
        };


        window.openJiFen = function() {
            api.alert({
                msg: '即将开放，敬请期待！',
            }, function(ret, err) {
                // if( ret ){
                //      alert( JSON.stringify( ret ) );
                // }else{
                //      alert( JSON.stringify( err ) );
                // }
            });

        }
    }
</script>

</html>
